package June;
import java.util.Objects;
import java.util.Scanner;
public class BerakExercise {
    public static void main(String[] args) {
        // 实现登录验证，有3次机会，
        // 如果用户名为"丁真”,密码"666"提示登录成功
        // 否则提示还有几次机会，请使用for+break完成

        Scanner myscanner = new Scanner(System.in);
        int opportunity = 3;
        for (int count = 1; count <= opportunity; count++) {
            System.out.println("请输入用户名：");
            String input_name = myscanner.next();
            System.out.println("请输入密码：");
            String input_password = myscanner.next();
            String name = "丁真";
            String password = "666";
            if (Objects.equals(input_name, name) && Objects.equals(input_password, password)) {
                System.out.println("恭喜你，登陆成功！");
                break;
            }
            if (count < opportunity) {
                System.out.println("你还有" + (opportunity - count) + "次输入密码的机会");
            }
            if (count == opportunity && !(Objects.equals(input_name, name) && Objects.equals(input_password, password))) {
                System.out.println("三次输入密码的机会以及用完！");
            }
        }
    }
}
